package com.example.leetcode.trainingcamp.week6.Sunday;

import java.util.ArrayList;
import java.util.List;

public class Offer54 {

    private List<Integer> list = new ArrayList<>();

    public int kthLargest(TreeNode root, int k) {
        insert(root);
        return list.get(list.size()-k);
    }

    public void insert(TreeNode root){
        if (root == null) return;
        insert(root.left);
        list.add(root.val);
        insert(root.right);
    }
}
